package com.yonyougov.devops.cruxcisupport;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {
    private final LoginInterceptor loginInterceptor;
    private final UpdatePassWordInterceptor updatePassWordInterceptor;


    public MyWebMvcConfig(LoginInterceptor loginInterceptor, UpdatePassWordInterceptor updatePassWordInterceptor) {
        this.loginInterceptor = loginInterceptor;
        this.updatePassWordInterceptor = updatePassWordInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**");
//                .excludePathPatterns("/swagger**")
//                .excludePathPatterns("/crux-cisupport/api/v2/login")
//                .excludePathPatterns("/**//ae/generatePort");
        registry.addInterceptor(updatePassWordInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns()
        ;
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
    }
}
